#include "Lexer.h"
#include "LexStream.h"
#include "../common/SrcMgr.h"

Lexer * Lexer::m_pLexerInstance = NULL;
Lexer::Lexer(void)
: m_pCurrentLexer(NULL)
{
}

Lexer::~Lexer(void)
{
}

int Lexer::nextToken( Token & tok )
{
	if(m_pCurrentLexer == NULL)
	{
		SrcMgr & srcs = SrcMgr::getInstance();
		std::pair<SourceID, SourceStream *> mainSrc = srcs.getMainSourceStream();
		m_pCurrentLexer = new LexStream(mainSrc.second);
	}
	return m_pCurrentLexer->nextToken(tok);
}

Lexer & Lexer::getInstance()
{
	if(m_pLexerInstance == NULL)
	{
		m_pLexerInstance = new Lexer();
	}
	return *m_pLexerInstance;
}